class Student(object):
    name = ''
    age = None
    __privateAage = None # __开头的是私有成员，只能类访问，类对象不能访问
    # 构造方法
    def __init__(self, name, age):
        self.name = name
        self.age = age
        print("构造方法执行了")
    # self  必须传；同时访问类成员必须用self.   就是ts中的this
    def __str__(self) -> str:
        return f"name: {self.name}, age: {self.age}"
    def __lt__(self, other):
        return self.age < other.age
    def __le__(self, other):
        return self.age < other.age
    def __eq__(self, other):
        return self.age == other.age
    def say_hello(self, msg):
        self.__say_hi() # 调用私有方法
        print('Hello %s %s' % (self.name,msg))
    def __say_hi(self): # 私有方法 只能在类内部使用
        print('hi')
if __name__ == '__main__':

    s = Student('xiaoming' , 20)
    s2 = Student('xiaoming' , 22)
    print(s <= s2) # 调用__lt__ 方法
    print(s == s2) # 调用__lt__ 方法
    print("__str__ 自动将类对象转为字符串：", s)
    # print(str(s)) #<__main__.Student object at 0x000001C00C786FF0> 内存地址，没啥用；
    s.say_hello(666)

    print(s.name)
    print(s.age)
    print(type(s)) # <class '__main__.Student'>